home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _94D99D3B376D4518B870C7EEF059A777 < prev    next >
Encoding:
Text File  |  2004-01-06  |  2.1 KB  |  68 lines

  1. -- linear patroling behaviour - 
  2. --Each character will patrol a set of TagPoints in a linear way ie 1 2 3 4 5 4 3 2 1 etc
  3.  
  4. --The character will approach each TagPoint sequentialy, look in the direction of the current TagPoint, 
  5. --make some idles and look around. After the last TagPoint he will return to his first point and start again.
  6. -- created by sten:         18-09-2002
  7. -- last modified by petar
  8. --------------------------
  9.  
  10. AIBehaviour.Job_PatrolLinear = {
  11.     Name = "Job_PatrolLinear",
  12.     JOB = 1,
  13.     
  14.     
  15.  
  16.     -- SYSTEM EVENTS            -----
  17.     ---------------------------------------------
  18.     OnSpawn = function(self,entity )
  19.         entity:InitAIRelaxed();
  20.         entity.AI_PathStep = 0;
  21.         entity.AI_SignIncrement = 1;
  22.         self:PatrolPath(entity);
  23.     end,
  24.  
  25.     OnJobContinue = function(self,entity )
  26.         entity:InitAIRelaxed();
  27.         self:PatrolPath(entity);
  28.     end,
  29.     ---------------------------------------------        
  30.     OnBored = function (self, entity)
  31.         entity:MakeRandomConversation();
  32.     end,
  33.     ----------------------------------------------------FUNCTIONS 
  34.     PatrolPath = function (self, entity, sender)
  35.         -- select next tagpoint for patrolling
  36.         local name = entity:GetName();
  37.  
  38.  
  39.         local tpname = name.."_P"..entity.AI_PathStep;
  40.  
  41.         local TagPoint = Game:GetTagPoint(name.."_P"..entity.AI_PathStep);
  42.         if (TagPoint== nil) then         
  43.  
  44.             if (entity.AI_PathStep == 0) then 
  45.                 System:Log("Warning: Entity "..name.." has a path job but no specified path points.");
  46.                 do return end
  47.             end
  48.  
  49.             entity.AI_SignIncrement = -entity.AI_SignIncrement;
  50.             entity.AI_PathStep = entity.AI_PathStep + entity.AI_SignIncrement;
  51.             tpname = name.."_P"..(entity.AI_PathStep + entity.AI_SignIncrement);
  52.         end
  53.  
  54.         
  55.         entity:SelectPipe(0,"patrol_approach_to",tpname);
  56.         entity.AI_PathStep = entity.AI_PathStep + entity.AI_SignIncrement;
  57.     end,
  58.     
  59.     ------------------------------------------------------------------------
  60.     -- GROUP SIGNALS
  61.     ------------------------------------------------------------------------
  62.     BREAK_AND_IDLE = function (self, entity, sender)
  63.     end,
  64.     ------------------------------------------------------------------------    
  65.     
  66. }
  67.  
  68.